package cn.com.api.mapper;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;

import cn.com.api.entity.ApiT_products;
import cn.com.api.resultpage.CarOrderPage;
import cn.com.api.mapper.base.T_productsMapperBase;
import cn.com.util.*;

//DAO
public interface ApiT_productsMapper extends T_productsMapperBase {

	// 根据商品id查询货品详情
	public List<Map<String, Object>> findProductsByGoodsId(
			@Param("goods_id") Long goods_id);
	
	public List<Map<String,Object>> searGoodIdAndCityId(@Param("goods_id") String goods_id,@Param("cityid") String cityid);

	// 根据商品id查询货品详情2
	/**
	 * 
	 * @param goods_id 
	 * @param isDeleted  是否查询已删除的（查询传1）
	 * @return
	 */
	public List<ApiT_products> getProductsByGoodsId(
			@Param("goods_id") Long goods_id,@Param("is_delete") Integer is_delete);

	// 反馈新增product_id
	public int insertT_productsReturnId(ApiT_products t_products);

	/** suyuanyuan start **/
	/** 根据product_ids 查询货品列表 */
	public List<CarOrderPage> searchProductsByProductIds(List<Long> list);

	/** suyuanyuan end **/
	
	// 添加erp 含id
 	public long insertT_products4erp(ApiT_products t_products);
 	
 	// 更新erp货品信息
	public int updateT_products4erp(ApiT_products t_products);
	
 	// 更新erp库存 
	public void updateProducts4erp(ApiT_products t_products);

	//
	public ApiT_products queryByGoodsId4erp(Integer goods_id);
	
	// 根据erp货品编码查询 所有仓库的货品  
	public List<ApiT_products> findProductsByErpProductId(String erp_product_id);
	
	public boolean updatePriceByPro(@Param("price")String price,@Param("proid")String proid,@Param("store")String store);
	
	public boolean updateTopOrDel(@Param("del") String del,@Param("status") String status,@Param("id") String id);
	
	//商铺端查询商品
	public List<ApiT_products> shopSearchGoodsByTypeListPage(@Param("map") Map<String, String> map, @Param("page") PageInfo page);

	//查询一个店铺的商品已售数量---店铺所有商品
	public int getSumSoldCountByShopId(Integer shop_id);
	
	//根据商品名称搜索商品
	public List<ApiT_products> searchProductsByGoodNameListPage(@Param("name")String name,@Param("city_id")String city_id,@Param("actid")String actid, @Param("page") PageInfo page);
	
	//根据product_id count --订单生成时 商品库存数量减少，已售数量增加
	public int reduceProductByProductId(@Param("product_id")Long product_id,@Param("count")Integer count);
	
	//根据product_id count --订单取消时 商品库存数量恢复(增加)，已售数量恢复(减少)
	public void recoveryProductByProductId(@Param("product_id")Long product_id,@Param("count")Integer count);
	
	public Map<String,Object> searByProId(@Param("proid")String proid);
	
	public String searStoreByProId(@Param("proid")String proid);
	
	// 根据city id和erp_product_id 获取
	public ApiT_products findProductByCityId_ErpProductId(@Param("city_id") Integer city_id, @Param("erp_product_id") String erp_product_id);
	
	/**
	 * 根据不同的查询条件分页得到product
	 * @param conditions
	 * @param pageInfo
	 * @return
	 */
	public List<ApiT_products> searchProductsListPage(@Param("map") Map<String,Object> conditions,@Param("page")PageInfo pageInfo);

	
	public List<ApiT_products> findZiYingproductss();
	
	/** 我收藏的商品  */
	public List<ApiT_products> findT_logs4GoodsByUserId(@Param("u_id") String u_id,@Param("city_id") String city_id);
	
	/** 美食外卖热销榜 */
	public Integer findProductsCountBySold(@Param("shop_id") String shop_id,@Param("sold") Integer sold);
	
	//订单支付时，校验erp库存是否充足，库存不足，提示
	public List<ApiT_products> findProductNotEnoughByOrdersId(@Param("list") String[] ordersId);
	
	
	public Map<String, Object> getGoodsInfoByProductId(String productId);
	
	public String getProductNameProductId(String productId);
	
	public void updStoreByProId(@Param(value="productId")String productId,@Param(value="num")Integer num);
	
	public void updIsDeleteByProductId(String productId);
	
	public ApiT_products getProByProductId(String productId);
	
	
	public void updateProducts(ApiT_products t_products);
	
	//public int selectByProductId(String productId);
	
	
}
